package Day06;

import java.util.Arrays;
import java.util.Scanner;

/*
需求：计算N位评委的平均分
 */
public class CalTotalAvg {
    public static void main(String[] args) {
        double[]scores=inputDate(6);
        double avg=calAvg(scores);
        System.out.println("平均分为"+avg);
    }
    //该方法用于录入N位评委的评分
    public static  double[] inputDate(int n){
        double[]scores=new double[n];
        Scanner scan=new Scanner(System.in);
        for (int i=0;i<scores.length;i++){
            System.out.println("请输入第"+(i+1)+"位评委的评分");
            scores[i]=scan.nextDouble();
        }
        return scores;
    }
    //该方法用于计算平均分
    public static double calAvg(double[]score){
        Arrays.sort(score);
        double avg=0.0,sum=0.0;

        for (int i=1;i<score.length-1;i++){
            sum=sum+score[i];
        }
        avg=sum/(score.length-2);
        return avg;
    }
}